<?php

class Elfinder_AdminController extends Zen_Controller_Admin {
	
	public function indexAction() {

		
		$this->_helper->layout->disableLayout();
		Zen_Style::add ( '/cms/application/modules/elfinder/res/elfinder/js/ui-themes/base/ui.all.css' );
		Zen_Style::add ( '/cms/application/modules/elfinder/res/elfinder/css/elfinder.css' );
		
		Zen_Script::add('/cms/application/modules/elfinder/res/elfinder/js/jquery-1.4.1.min.js');
		Zen_Script::add('/cms/application/modules/elfinder/res/elfinder/js/jquery-ui-1.7.2.custom.min.js');
		Zen_Script::add('/cms/application/modules/elfinder/res/elfinder/js/elfinder.min.js');
		
		Zen_Style::add ( '/cms/application/modules/elfinder/res/css/ef.css' );
		Zen_Script::add('/cms/application/modules/elfinder/res/js/ef.js');
		
		$this->_helper->layout->setLayout ( 'ef' );
	}
	
	public function connectorAction() {
		include_once "elFinder.class.php";
		$this->_helper->layout->disableLayout();
		
		$fdir = dirname ( $_SERVER ['SCRIPT_FILENAME']) . "/site/upload/userfiles";

		$opts = array(
			'root'            => $fdir,                       // path to root directory
			'URL'             => '/site/upload/userfiles/', // root directory URL
			'rootAlias'       => 'Home',       // display this instead of root directory name
			'uploadAllow'   => array('all'),
		//'uploadDeny'    => array('all'),
		//'uploadOrder'   => 'deny,allow'
		// 'disabled'     => array(),      // list of not allowed commands
			 'dotFiles'     => false,        // display dot files
			 'dirSize'      => false,         // count total directories sizes
			 'fileMode'     => 0777,         // new files mode
			 'dirMode'      => 0777,         // new folders mode
			 'mimeDetect'   => 'auto',       // files mimetypes detection method (finfo, mime_content_type, linux (file -ib), bsd (file -Ib), internal (by extensions))
			 'uploadAllow'  => array('all'),      // mimetypes which allowed to upload
			 'uploadDeny'   => array(),      // mimetypes which not allowed to upload
			 'uploadOrder'  => 'deny,allow', // order to proccess uploadAllow and uploadAllow options
			 'imgLib'       => 'auto',       // image manipulation library (imagick, mogrify, gd)
			 'tmbDir'       => '.tmb',       // directory name for image thumbnails. Set to "" to avoid thumbnails generation
			 'tmbCleanProb' => 1,            // how frequiently clean thumbnails dir (0 - never, 100 - every init request)
			 'tmbAtOnce'    => 5,            // number of thumbnails to generate per request
			 'tmbSize'      => 48,           // images thumbnails size (px)
			 'fileURL'      => true,         // display file URL in "get info"
			 'dateFormat'   => 'j M Y H:i',  // file modification date format
			 'logger'       => null,         // object logger
			 'defaults'     => array(        // default permisions
			 	'read'   => true,
			 	'write'  => true,
			 	'rm'     => true
		),
		//'perms'        => array(),      // individual folders/files permisions
			 'debug'        => true,         // send debug to client
			 'archiveMimes' => array(),      // allowed archive's mimetypes to create. Leave empty for all available types.
		//'archivers'    => array()       // info about archivers to use. See example below. Leave empty for auto detect
			 'archivers' => array(
			 	'create' => array(
			 		'application/x-gzip' => array(
			 			'cmd' => 'tar',
			 			'argc' => '-czf',
			 			'ext'  => 'tar.gz'
		)
		),
			 	'extract' => array(
			 		'application/x-gzip' => array(
			 			'cmd'  => 'tar',
			 			'argc' => '-xzf',
			 			'ext'  => 'tar.gz'
		),
			 		'application/x-bzip2' => array(
			 			'cmd'  => 'tar',
			 			'argc' => '-xjf',
			 			'ext'  => 'tar.bz'
		)
		)
		)
		
		);
		
		$fm = new elFinder($opts);
		$fm->run();
	
	}

}